<extend name="Public/base"/>

<block name="body">
	<div class="main-title">
		<h2>视图数据管理 [ <strong>全部</strong>]</h2>
	</div>

	<div class="cf">
		<a class="btn" href="{:U('editDB?vid='.$vid)}">新 增</a>
		<a class="btn" href="{:U('tableView?id='.$tid)}">返回</a>
		<!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
				<input type="text" name="name" class="search-input" value="{:I('name')}" placeholder="请输查询数据">
				<input type="hidden" name="vid" value="{:I('vid')}"/>
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('config/viewList')}"><i class="btn-search"></i></a>
			</div>
		</div>
	</div>

	<div class="data-table table-striped">
		<table>
			<thead>
				<tr>
					<notempty name="viewcolumn">
						<th>编号</th>
						<foreach name="viewcolumn" item="vo">
						    <th>{$vo['fnamec']}</th>
						</foreach>
						<th>操作</th>
					</notempty>
				</tr>
			</thead>
			<tbody>
				<notempty name="viewList">
					<foreach name="viewList" item="config">
						<tr>
							<foreach name="config" item="vo">
								<td>{$vo}</td>
							</foreach>
							<td>
								<a title="编辑" href="{:U('editDB?vid='.I('vid').'&id='.$config['id'])}">编辑</a>
								<a class="confirm ajax-get" title="删除" href="{:U('delDB?vid='.I('vid').'&id='.$config['id'])}">删除</a>
							</td>
						</tr>
					</foreach>
				<else/>
				<td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
				</notempty>
			</tbody>
		</table>
		<!-- 分页 -->
	    <div class="page">
	        {$_page}
	    </div>
	</div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});
});
</script>
</block>